home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / ici / ici.cpi / float.c < prev    next >
C/C++ Source or Header  |  1994-10-27  |  802b  |  57 lines

  1. #include "float.h"
  2.  
  3. float_t *
  4. new_float(v)
  5. double    v;
  6. {
  7.     register float_t    *f;
  8.     static float_t    proto = {OBJ(TC_FLOAT, float_type)};
  9.  
  10.     proto.f_value = v;
  11.     if ((f = floatof(atom_probe(objof(&proto)))) != NULL)
  12.     {
  13.     got(f);
  14.     return f;
  15.     }
  16.     if ((f = talloc(float_t)) == NULL)
  17.     return NULL;
  18.     *f = proto;
  19.     rego(f);
  20.     return floatof(atom(objof(f), 1));
  21. }
  22.  
  23. STATIC long
  24. mark_float(o)
  25. object_t    *o;
  26. {
  27.     o->o_flags |= O_MARK;
  28.     return sizeof(float_t);
  29. }
  30.  
  31. STATIC int
  32. cmp_float(f1, f2)
  33. float_t    *f1;
  34. float_t    *f2;
  35. {
  36.     return f1->f_value != f2->f_value;
  37. }
  38.  
  39. STATIC long
  40. hash_float(f)
  41. float_t    *f;
  42. {
  43.     return *(long *)&f->f_value;
  44. }
  45.  
  46. type_t    float_type =
  47. {
  48.     mark_float,
  49.     free_simple,
  50.     hash_float,
  51.     cmp_float,
  52.     copy_simple,
  53.     assign_simple,
  54.     fetch_simple,
  55.     "float"
  56. };
  57.